Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
3 / 3
CRAP
100.00% covered (success)
100.00%
8 / 8
UserTest
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
3 / 3
3
100.00% covered (success)
100.00%
8 / 8
 setUp
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
3 / 3
 tearDown
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 testArray
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
4 / 4
<?php
use PHPUnit\Framework\TestCase;
/**
 * Created by PhpStorm.
 * User: Viktor
 * Date: 01.05.2019
 * Time: 16:31
 */
class UserTest extends TestCase
{
    private $user;
    protected function setUp() : void
    {
        $this->user = new \App\Models\User();
        $this->user->setAge(33);
        //$this->user->setEmail("admin@admin.com");
    }
    protected function tearDown(): void
    {
    }
    /*public function testAge1() {
        /// 33 === $this->user->getAge()
        $this->assertSame('33', $this->user->getAge());
        return 33;
    }*/
    /**
     * dataProvider userProvider
     * dataProvider userProvider2
     */
    /*public function testAge2($age) {
        /// 33 == $this->user->getAge()
        $this->assertEquals($age, $this->user->getAge());
    }
    public function userProvider() {
        return [
            [1, 2, 3],
            [2, 2, 5],
            [33, 35,4],
        ];
    }
    public function userProvider2() {
        return [
            [-1, 2,3],
            [2, -2, 5],
            [33, -35,4],
        ];
    }*/
    /**
     * expectedException InvalidArgumentException
     */
    /*public function testEmailException() {
        $this->expectException(\PHPUnit\Framework\Error\Error::class);
        include "somefilenotexist.php";
        //$this->expectExceptionCode(10);
        //$this->expectExceptionMessage("Error email1");
        //$this->expectExceptionMessageRegExp("/\d/");
        $this->user->getEmail();
        ///test ..
    }*/
    /*public function testAddToFile() {
        $this->assertFalse(@$this->addToFile("/asdasd/asomefile.txt", "data to save"));
    }
    public function addToFile($path, $data) {
        $file = fopen($path, 'w');
        //// ....
        ///
        ///
        if($file == false) {
            return false;
        }
    }*/
    /*public function testEcho() {
        $this->expectOutputString("success");
        $this->setOutputCallback(function($str) {
            return trim($str);
        });
        //$this->expectOutputRegex("/\d/");
        echo "success ";
    }*/
    /*public function testArray() {
        $this->assertSame(
            [12,2,3,34,34,34,34,343,434,34,21,2,3,4],
            [12,2,3,34,34,344,34,343,434,34,1,2,3,4]
        );
    }*/
    public function testArray() {
        /// ===
        $this->assertEquals(
            [1,2,3,4,5,6,7,8,9,10],
            ['1',2,3,4,5,6,7,8,9,10]
        );
    }
}